package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.common.utils.DateUtils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ruoyi.system.mapper.AdminBookMapper;
import com.ruoyi.system.domain.AdminBook;
import com.ruoyi.system.service.IAdminBookService;
import com.ruoyi.common.core.text.Convert;

/**
 * 教材Service业务层处理
 * 
 * @author ruoyi
 * @date 2020-06-10
 */
@Service
public class AdminBookServiceImpl implements IAdminBookService 
{
    @Autowired
    private AdminBookMapper adminBookMapper;

    /**
     * 查询教材
     * 
     * @param bookId 教材ID
     * @return 教材
     */
    @Override
    public AdminBook selectAdminBookById(Long bookId)
    {
        return adminBookMapper.selectAdminBookById(bookId);
    }

    /**
     * 查询教材列表
     * 
     * @param adminBook 教材
     * @return 教材
     */
    @Override
    public List<AdminBook> selectAdminBookList(AdminBook adminBook)
    {
        return adminBookMapper.selectAdminBookList(adminBook);
    }

    /**
     * 新增教材
     * 
     * @param adminBook 教材
     * @return 结果
     */
    @Override
    public int insertAdminBook(AdminBook adminBook)
    {
        adminBook.setCreateTime(DateUtils.getNowDate());
        return adminBookMapper.insertAdminBook(adminBook);
    }

    /**
     * 修改教材
     * 
     * @param adminBook 教材
     * @return 结果
     */
    @Override
    public int updateAdminBook(AdminBook adminBook)
    {
        adminBook.setUpdateTime(DateUtils.getNowDate());
        return adminBookMapper.updateAdminBook(adminBook);
    }

    /**
     * 删除教材对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteAdminBookByIds(String ids)
    {
        return adminBookMapper.deleteAdminBookByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除教材信息
     * 
     * @param bookId 教材ID
     * @return 结果
     */
    @Override
    public int deleteAdminBookById(Long bookId)
    {
        return adminBookMapper.deleteAdminBookById(bookId);
    }
    
    /**
     * 教材状态修改
     * 
     * @param class 教材信息
     * @return 结果
     */
    @Override
    public int changeStatus(AdminBook adminBook)
    {
        return adminBookMapper.updateAdminBook(adminBook);
    }
}
